package cn.bob.org.service.impl;

import cn.bob.basic.query.BaseQuery;
import cn.bob.basic.utils.PageList;
import cn.bob.org.domain.Dictionarydetail;
import cn.bob.org.mapper.DictionarydetailMapper;
import cn.bob.org.query.DictionarydetailQuery;
import cn.bob.org.service.IDictionarydetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author bob
 * @data 2022/10/13-9:11
 */
@Service
public class DictionarydetailServiceImpl implements IDictionarydetailService {
    @Autowired
    private DictionarydetailMapper mapper;

    @Override
    public void add(Dictionarydetail dictionarydetail) {
        mapper.add(dictionarydetail);
    }

    @Override
    public void delById(Long id) {
        mapper.delById(id);
    }

    @Override
    public void batchDel(List<Long> ids) {
        mapper.batchDel(ids);
    }

    @Override
    public void update(Dictionarydetail dictionarydetail) {
        mapper.update(dictionarydetail);
    }

    @Override
    public List<Dictionarydetail> findAll() {
        return mapper.findAll();
    }

    @Override
    public Dictionarydetail findById(Long id) {
        return mapper.findById(id);
    }

    @Override
    public Integer queryByCount(DictionarydetailQuery query) {
        return mapper.queryByCount(query);
    }

    @Override
    public PageList<Dictionarydetail> queryByPage(DictionarydetailQuery query) {
        if (!StringUtils.isEmpty(query)){
            query.setKeyword(query.getKeyword().trim());
        }
        Integer integer = mapper.queryByCount(query);
        List<Dictionarydetail> dictionarydetails = mapper.queryByPage(query);
        return new PageList<Dictionarydetail>(dictionarydetails,integer);
    }
}
